<?php

	if (isset($_SESSION[$ssUserID])){
		if (!$_SESSION[$ssUserID] == ""){
			redirect("?act=info");	
		}
	}
?>

<link rel="stylesheet" href="../css/style_login.css" type="text/css" />

<script type='text/javascript'>
	


	
Ext.onReady(function(){
	$('#submit').click(function(){
		var username = $('#user_login').val().trim();
		var password = $('#user_pass').val().trim();
		if (username && password) {
			Ext.Ajax.request({
				url: 'services/check_login.php',
				method: 'POST',
				params: {
					username: username,
					password: password
				},
				success: function(result, request){
					if(result.responseText == 0){
						$("#login_error").removeClass('hidden');
						$("#login_error").html("ERROR: Invalid username or password");
						$("#login_error").show();
						addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};
						function s(id,pos){g(id).left=pos+'px';}
						function g(id){return document.getElementById(id).style;}
						function shake(id,a,d){c=a.shift();s(id,c);if(a.length>0){setTimeout(function(){shake(id,a,d);},d);}else{try{g(id).position='static';wp_attempt_focus();}catch(e){}}}
						addLoadEvent(function(){ var p=new Array(15,30,15,0,-15,-30,-15,0);p=p.concat(p.concat(p));var i=document.forms[0].id;g(i).position='relative';shake(i,p,20);});

					}
					if (result.responseText == 1){
						$("#login_error").removeClass('hidden');
						$("#login_error").addClass('hidden');
						window.location = "?act=info"; 
					}
				}
			});
		}else{
			$("#login_error").removeClass('hidden');
			$("#login_error").html("ERROR: Invalid username or password");
			$("#login_error").show();
		}
//		alert("ERROR: Invalid username. Lost your password?");
	});
});

</script>
<h1>Wheel House</h1>
<div class="hidden" id='login_error'></div>
<form method="post" action="#" id="loginform" name="loginform">
	<p>
		<label>Username<br>
		<input type="text" tabindex="10" size="20" value="" class="input" id="user_login" name="log"></label>
	</p>
	<p>
		<label>Password<br>
		<input type="password" tabindex="20" size="20" value="" class="input" id="user_pass" name="pwd"></label>
	</p>
	<p class="submit">
		<input type="button" tabindex="100" value="Log In" class="button-primary" id="submit" name="submit">
	</p>
</form>